import sys, os, pwd, signal, time
from resource_management import *
from subprocess import call
from resource_management.core.logger import Logger
from resource_management.libraries.functions import format
from resource_management.core.resources.system import Execute, File
from resource_management.libraries.functions.check_process_status import check_process_status
from resource_management.core import shell

class Slave(Script):
  def install(self, env):
    import params
    env.set_params(params)
    print "Master install method"
    # Install packages listed in metainfo.xml
    # self.install_packages(env)
    print "aimport config:",params.log_file,params.war_url,params.servlet_server_tar_url
    Logger.info("this is logger print message")
    Logger.error("this is logger  print message,the level is error")
    Logger.warning("this is logger print message,the level is warning")
    Logger.debug("this is logger print message,the level is debug")
    Logger.info(format("ddse config-logfile is:{log_file}"))



  #To stop the service, use the linux service stop command and pipe output to log file
  def stop(self, env):
      Logger.info("this is logger print message")
      # Logger.error("this is logger  print message,the level is error")
      # Logger.warning("this is logger print message,the level is warning")
      # Logger.debug("this is logger print message,the level is debug")


  #To start the service, use the linux service start command and pipe output to log file
  def start(self, env):
      Logger.info("this is logger print message")
      # Logger.error("this is logger  print message,the level is error")
      # Logger.warning("this is logger print message,the level is warning")
      # Logger.debug("this is logger print message,the level is debug")


  #To get status of the, use the linux service status command
  def status(self, env):
    import status_params
    env.set_params(status_params)
    check_process_status(status_params.webapp_pid)

if __name__ == "__main__":
    Slave().execute()
